
<?php
require_once 'config.php';



/*
 * All the common functions will be written here
*/
/*
 *	Gets the list of banners
*/
function getBannerList()
{

	$sql = "SELECT 	bn_id, 
					bn_header, 
					bn_image,
					bn_description 					
			FROM 	tbl_banner
		ORDER BY 	bn_date DESC";
    $result = dbQuery($sql);

    $banner = array();
    while ($row = dbFetchAssoc($result)) {
		extract($row);
		
		if ($bn_image) {
			$bn_image = WEB_ROOT . 'images/banner/' . $bn_image;
		} else {
			$bn_image = WEB_ROOT . 'images/no-image-small.png';
		}
		
		$banner[] = array('url'   => $_SERVER['PHP_SELF'] . '?c=' . $bn_id,
		               'image' => $bn_image,
					   'name'  => $bn_header,
					   'description' => $bn_description);
    }

	return $banner;			
}


/*
 * Gets the list of branches
 * this method will generate the branch list
*/
function getBranchList()
{

	$sql = "SELECT br_id, br_name 
			FROM tbl_branch b 
			WHERE br_status='ACT' 
			ORDER BY br_name";
    $result = dbQuery($sql);

    $branch= array();
    while ($row = dbFetchAssoc($result)) {
		extract($row);
		$branch[] = array('br_id' => $br_id, 'br_name' => $br_name);
    }

	return $branch;			
}

?>